// pages/tabbar/tabbar.js
let app = getApp();
let __this = this;
Component({

  options: {
    addGlobalClass: true,//使用app.wxss样式
    styleIsolation: 'shared'
  },

  /**
   * 组件的属性列表
   */
  properties: {
    index: {
      type: Number,
      //监听数据变化
      observer(newVal,oldVal,changedPath){
          if(newVal)
            this.setData({active: newVal})
      }
    },
    cartTotal: {
      type: String,
      //监听数据变化
      observer(newVal,oldVal,changedPath){
          this.setData({dataCartTotal: newVal})
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    dataCartTotal: '',
    active: 0,
    list: [
      {
        icon: 'wap-home-o',
        text: '首页',
        url: '/pages/index/index'
      },
      {
        icon: 'tv-o',
        text: '直播中心',
        url: '/pages/liveList/liveList'
      },
      {
        icon: 'shopping-cart-o',
        text: '购物车',
        url: '/pages/cart/cart'
      },
      {
        icon: 'manager-o',
        text: '我的',
        url: '/pages/user/user'
      }
    ]
  },

  lifetimes: {
    attached(){
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {

    //tabbar切换
    tabbarChange(event){
      let index = event.detail;
      wx.switchTab({
        url: this.data.list[index].url
      });
    },
  }
})
